﻿<%@ Page Language="C#" AutoEventWireup="true" Codebehind="UserDefault.aspx.cs" Inherits="LabMS.Web.User.UserDefault" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>用户管理</title>
    <link type="text/css" rel="stylesheet" href="../style/screen.css" />
    <!--[if lte IE 6]>
    <link type="text/css" rel="stylesheet" href="../style/ie6.css" />
    <![endif]-->
    <!--[if lte IE 7]>
    <link type="text/css" rel="stylesheet" href="../style/ie7.css" />
    <![endif]-->
</head>
<body class="mainBody">
    <form id="form1" runat="server">
        <div class="main">
            <div id="pageInfo" class="clearfix">
                <div class="title">
                    <label>
                        用户管理</label>
                </div>
            </div>
        </div>
        <div class="main">
            <p>
                <input type="button" class="button" value="新增" onclick="javascript:window.location.href='Add.aspx'" />
                <%--<asp:Button ID="addUser" runat="server" Text="新增" CssClass="button" OnClick="addUser_Click" />--%>
                <asp:Button ID="cancleUser" runat="server" Text="删除" CssClass="button" OnClick="cancleUser_Click" />
            </p>
            <p>
                <span>用户名：</span><asp:TextBox ID="tbusernameSearch" runat="server"></asp:TextBox>
                <asp:Button ID="search" runat="server" Text="搜索" OnClick="search_Click" CssClass="button" />
            </p>
        </div>
        <div class="main">
            <asp:GridView ID="gvuser" runat="server" CssClass="infoTable" Width="100%" DataKeyNames="UserId"
                AutoGenerateColumns="false" AllowPaging="true" PageSize="10" OnPageIndexChanging="gvuser_PageIndexChanging"
                OnRowDataBound="gvuser_RowDataBound">
                <Columns>
                    <asp:TemplateField ItemStyle-CssClass="checkBox">
                        <HeaderTemplate>
                            <asp:CheckBox ID="CBAll" runat="server" />
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="chkchoose" runat="server" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="UserId" ShowHeader="false" Visible="false" />
                    <%--<asp:HyperLinkField DataNavigateUrlFields="UserId" Target="_blank" DataNavigateUrlFormatString="EditUser.aspx?UserId={0}"
                        NavigateUrl="EditUser.aspx" HeaderText="用户名" DataTextField="UserName" />--%>
                    <asp:BoundField DataField="UserName" HeaderText="用户名" />
                    <asp:BoundField DataField="RealName" HeaderText="真实姓名" />
                    <asp:BoundField DataField="CreateTime" HeaderText="加入时间" DataFormatString="{0:yyyy-MM-dd}" />
                </Columns>
                <EmptyDataTemplate>
                    暂时没有数据！
                </EmptyDataTemplate>
                <HeaderStyle CssClass="header" />
                <RowStyle HorizontalAlign="Center" />
                <PagerSettings FirstPageText="首页" LastPageText="最后页" NextPageText="后一页" PreviousPageText="前一页"
                    Mode="NextPreviousFirstLast" />
            </asp:GridView>
        </div>
    </form>

    <script type="text/javascript" src="../js/jQuery/jquery-1.3.1.js"></script>

    <script type="text/javascript" src="../js/jQuery/jquery.tooltip.js"></script>

    <script type="text/javascript" src="../js/jQuery/jquery.bgiframe.js"></script>

    <script type="text/javascript" src="../js/jQuery/jquery.validate.js"></script>

    <script type="text/javascript" src="../js/site.js"></script>

</body>
</html>

<script type="text/javascript" src="../../js/jQuery/jquery-1.3.1.js"></script>

<script type="text/javascript">

        $(function(){
            /* 修改样式 */
            $("#gvuser > tbody > tr:even").not(":first").addClass("even");
            $("#gvuser > tbody > tr").not(":first")
                .hover(
                    function(){
                        $(this).addClass("hover");
                    },
                    function(){
                        $(this).removeClass("hover");
                });

            /* 全选 */
            $("#gvuser > tbody > tr:first :checkbox").click(function(){
                if ($(this).attr("checked")){
                    $("#gvuser :checkbox").attr("checked", "checked");
                    cbChanged();
                } else{
                    $("#gvuser :checkbox").attr("checked", "");
                    cbChanged();
                }
            });

            /* Checkbox事件 */
            $("#gvuser :checkbox").not(":first").click(cbChanged);

            cbChanged();
        });

        /* 检测Checkbox的选择状态，更改button的disabled属性 */
        function cbChanged(){
            var hasChecked = false;
            var allChecked = true;
            $("#gvuser :checkbox").not(":first").each(function(index, domEle){
                var curChecked = $(domEle).attr("checked");
                if (!hasChecked && curChecked){
                    hasChecked = true;
                }

                allChecked &= curChecked;
            });

            if (hasChecked){
                $("#cancleUser").attr("disabled", "");
            } else {
                $("#cancleUser").attr("disabled", "disabled");
            }

            if (allChecked){
                $("#gvuser :checkbox").filter(":first").attr("checked", "checked");
            } else {
                $("#gvuser :checkbox").filter(":first").attr("checked", "");
            }
        }
</script>

